#include "my_head.h"

bool Login(p_user_node head,int* a,char *p)
{   
    if(head==NULL)
    {
        printf("error\n");
        return false;
    }
    p_user_node b=head->next;
    
    printf("请输入你的账号:");
    scanf("%d",a);
    printf("请输入你密码:");
    scanf("%s",p);
    if(*a==123&&strcmp(p,"123")==0)
    {
        head->data.user_account.permission=1;
        printf("管理员登录成功！\n");
        printf("===============\n");
        return true;
    }
    while(b!=NULL&&(*a!=b->data.user_account.id||strcmp(p,b->data.user_account.password)!=0))
    {
        b=b->next;
    }
    if(b!=NULL)
    {
        b->data.user_account.permission=2;
        printf("用户登录成功！\n");
        printf("================\n");
        return true;
    }else
    {
        printf("登录失败,请重新登录！\n");
        printf("================\n");
        return false;
    }
}